# -*- coding: utf-8 -*-
from wechatpy import WeChatClient
from urllib.parse import quote


# def make_url_with_action(action):
#     url = Base.baseUrl + "/login_callback?" + "action=" + action
#     callback_url = quote(url)
#     login_url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxe566d7c50a4d2cf9&redirect_uri=" + \
#                 callback_url + "%2Fauth&response_type=code&scope=snsapi_base&state=STATE"
#     return login_url

def setMenu():
    MENU = {
        "button": [
            {
                "type": "view",
                "name": "定位轨迹",
                "url": "http://weixin.pbani.com/wx/index?action=device_map",
                "key": "device_list"
            },
            {
                "type": "view",
                "name": "功能管理",
                "url": "http://weixin.pbani.com/wx/index?action=view_device",
                "key": "device_chat"
            },
            {
                "type": "view",
                "name": "收发消息",
                "url": "http://weixin.pbani.com/wx/index?action=record",
                "key": "device_list"
            }
        ]
    }
    client = WeChatClient('wxe566d7c50a4d2cf9', '22e51f3c77de185205a9a0cf51c942dc')
    res = client.menu.create(MENU)
    print(res)


# def delMenu(appid, secret):
#     client = WeChatClient(appid, secret)
#     menu = client.menu.get()
#     if menu is not None:
#         client.menu.delete()
#
#
# def getMenu():
#
#     client = WeChatClient(WX.get('appid'), WX.get('appsecret'))
#     menu = client.menu.get()
#     print(menu)


if __name__ == '__main__':
    setMenu()
